package com.qfedu.mesadmin.dev.mainn.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.qfedu.mes.common.PageVO;
import com.qfedu.mes.entity.dev.MainProject;
import com.qfedu.mesadmin.dev.mainn.dao.MainProjectDAO;
import com.qfedu.mesadmin.dev.mainn.params.SearchParam;
import com.qfedu.mesadmin.dev.mainn.service.MainProjectService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MainProjectServiceImpl implements MainProjectService {
    @Resource
    private MainProjectDAO mainProjectDAO;
    @Override
    public PageVO<MainProject> pageList(SearchParam param) {
        PageHelper.startPage(param.getPageNum(),param.getPageSize());
        List<MainProject> mainProjects = mainProjectDAO.pageInfo(param);
        Page pageInfo=(Page) mainProjects;
        PageVO<MainProject> pageVO=new PageVO<>();
        pageVO.setTotal(pageInfo.getTotal());
        pageVO.setDataList(mainProjects);
        return pageVO;
    }

    @Override
    public void addMainProject(MainProject project) {
        mainProjectDAO.insert(project);
    }
}
